package com.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 继承netty方法模板（netty提供的规范）
 */
public class NettyServerHandler extends ChannelInboundHandlerAdapter {


    /**
     * netty处理连接事件
     * @param ctx
     * @throws Exception
     */
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("连接完成"+ctx.toString());
        super.channelActive(ctx);
    }

    /**
     * netty处理读事件
     * @param ctx
     * @param msg
     * @throws Exception
     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
//        System.out.println("输出:"+msg);
        super.channelRead(ctx, msg);
    }
}
